<?php
/**
 * Created by PhpStorm.
 * User: Bu
 * Date: 2018/1/15
 * Time: 15:35
 */

namespace app\admin\controller;
use \app\common\model\Admin;

use think\Controller;

class Login extends Controller
{
    public function index(Admin $admin)
    {
        if (request()->isPost())
        {
            $res= $admin->getAdmin(input('post.'));
            if ($res['valid']==1)
            {
                return $this->success($res['message'],url('admin/entry/index'));#登陆成功

            }
            if ($res['valid']==2)
            {
                return $this->success($res['message']);#密码错误
            }
            if ($res['valid']==3)
            {
                return $this->success($res['message']);#用户名不存在
            }
        }
        return view();
    }
    public function loginout()
    {
        session(null);
        return $this->success('退出成功',url('admin/login/index'));
    }
}